#load "unix.cma";;
#load "graphics.cma";;

#load "bplib.cma";;

open Graphics;;
open Bplib;; 
open BplibTypes;;

Protocole.of_string "MTO $23 \"toto\" \"bibi\" 10010";;
Protocole.reponse_of_string "$12";;

let r = new ram "Exemple" 4 7 [||];;

let _ = 
  open_graph " 300x300";
  set_window_title "Exemple";
  r#draw;;

let read i = 
  r#read_user_value i;
  r#draw;;

r#set_type_view Binaire;;
r#draw;;
r#set_type_view SignedDecimal;;
read 11;;

let _ =
  r#set_color 4 blue;
  r#set_type_view Decimal;
  r#write 5 46;
  r#write 2 (-1);;

let _ =
  r#set_type_view SignedDecimal;
  r#center 4;
  r#where_is 8;
  r#incr_offset;
  r#main_loop;;


read_string 0 0 ~length:6 "";;



(* Lecture binaire *)
let t = BoolArray.of_string "1001100110011111";;
BoolArray.to_bin_file t "toto1001.bin";;

let o = BoolArray.of_asci_file "cc.ascii";;
BoolArray.to_bin_file o "cc.bin";;

(* Display *)

Display.sprintf "Format toto '%4d' '%3b' et '%3n'" (Array.map (function 0 -> false | 1 -> true ) [|1;0;0;0;1;0;1;0;1;1|]);;
